package com.lzy.webapi.facade;

import com.github.pagehelper.PageInfo;
import com.lzy.coupon.apis.MotorcycleSpecServiceApi;
import com.lzy.coupon.dtos.MotorcycleDto;
import com.lzy.coupon.dtos.MotorcycleSpecDto;
import com.lzy.coupon.service.MotorcycleService;
import com.lzy.framework.core.datasource.multiple.DataSource;
import com.lzy.framework.core.datasource.multiple.DataSourceHolder;
import com.lzy.framework.core.ensure.Ensure;
import com.lzy.framework.core.orm.db.Pager;
import com.lzy.framework.core.utils.DozerUtils;
import com.lzy.member.apis.MemberUserServiceApi;
import com.lzy.member.dtos.MemberUserDto;
import com.lzy.product.apis.AgentProductServiceApi;
import com.lzy.product.apis.ProductUserServiceApi;
import com.lzy.product.apis.ProjectServiceApi;
import com.lzy.product.constants.BusinessType;
import com.lzy.product.dtos.ProductUserDto;
import com.lzy.product.dtos.ProjectDto;
import com.lzy.product.dtos.agent.AgentProductDto;
import com.lzy.product.dtos.agent.AgentProductImageTextDto;
import com.lzy.product.dtos.agent.AgentProductMotorcycleDto;
import com.lzy.product.dtos.agent.AgentProductProjectDto;
import com.lzy.product.entity.AgentProductImageText;
import com.lzy.product.service.AgentProductImageTextService;
import com.lzy.product.service.AgentProductProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by WIN7 on 2018/4/13.
 */
@Component
public class AgentProductFacade {

    @Autowired
    private AgentProductServiceApi agentProductServiceApi;

    @Autowired
    private AgentProductImageTextService agentProductImageTextService;

    @Autowired
    private AgentProductProjectService agentProductProjectService;

    @Autowired
    private ProjectServiceApi projectServiceApi;

    @Autowired
    private ProductUserServiceApi productUserServiceApi;

    @Autowired
    private MemberUserServiceApi memberUserServiceApi;

    /**
     * 移动端查询产品列表
     * @param pager
     * @param paramDto
     * @return
     */
    public PageInfo<AgentProductDto> queryProductList(Pager pager, AgentProductDto paramDto, Long userId) {
//        DataSourceHolder.setDataSource(DataSource.DATASOURCE_COMMON);
//        MemberUserDto memberUserDto = memberUserServiceApi.findById(userId);
//        Ensure.that(memberUserDto).isNotNull("01001505");
//        DataSourceHolder.clearDataSource();
//        ProductUserDto productUserDto = productUserServiceApi.queryByPhone(memberUserDto.getAccount());
//        Ensure.that(productUserDto).isNotNull("01001505");
//        paramDto.setUserId(productUserDto.getId());
        return agentProductServiceApi.queryAgentProductListByMobile(pager, paramDto);
    }

    /**
     * 根据id查询产品
     *
     * @param id
     * @return
     */
    public AgentProductDto queryAgentProductById(Long id) {
        return agentProductServiceApi.queryAgentProductById(id);
    }

}
